﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace HRProject.Code.Common
{
    public static class BLAuthentication
    {
        private static string admin = "Admin";
        private static string manager = "Manager";
        //private static string agent = "Agent";

        public static bool IsAddAllowed
        {
            get
            {
                return Membership.GetUser() != null
                && (Roles.IsUserInRole(admin) || Roles.IsUserInRole(manager));
            }
        }

        public static bool IsEditAllowed
        {
            get
            {
                return Membership.GetUser() != null
                && (Roles.IsUserInRole(admin) || Roles.IsUserInRole(manager));
            }
        }

        public static bool IsRemoveAllowed
        {
            get
            {
                return Membership.GetUser() != null
                && (Roles.IsUserInRole(admin) || Roles.IsUserInRole(manager));
            }
        }

        public static Guid CurrentUserId
        {
            get
            {
                MembershipUser user = Membership.GetUser();
                if (user != null)
                {
                    return (Guid)user.ProviderUserKey;
                }
                return Guid.Empty;
            }
        }
    }
}
